<!--
 * @Description: 直属平台审核结果
 * @Autor: 何兴家
 * @Date: 2021-03-26 09:51:24
 * @LastEditors: 何兴家
 * @LastEditTime: 2021-03-26 13:59:32
-->
<template>
  <div style="display: inline-block; margin-right: 10px">
    <el-button type="primary" :disabled="disabled" @click="handleShowPanel">审核结果</el-button>

    <BaseDialog :visible.sync="showPanel" title="审核结果" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <FilterTable
        ref="table"
        height="auto"
        :columns="columns"
        :fetchapi="fetchapi"
        :isSelectColumn="false"
        :params="fetchParams"
        :datakey="'rows'"
        :isPagination="false"
        :onSyncTableData="handleSyncTableData"
        :onColumnsChange="columns => (this.columns = columns)"
      >
        <template slot="controls">
          <el-button size="small" type="primary" @click="handleRefesh">刷新</el-button>
        </template>
      </FilterTable>
      <div class="dialogBottmView">
        <el-button type="primary" @click="showPanel = false">确定</el-button>
      </div>
    </BaseDialog>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { confirmAction, notifyAction, findFormItem, findTableItem } from '@/utils';

import { queryRepairOrderAuditResult } from '@/api/repair/repairReception/customer';

export default {
  props: {
    disabled: {
      type: Boolean,
      default: true
    },
    roNo: String
  },
  mixins: [dictionary],
  data() {
    return {
      columns: this.createTableColumns(),
      fetchapi: queryRepairOrderAuditResult,
      fetchParams: { xhrAbort: true },
      showPanel: false,
      syncTableData: [] // 同步的table数据
    };
  },
  methods: {
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '审核日期',
          dataIndex: 'AUDIT_DATE'
        },
        {
          title: '审核结果',
          dataIndex: 'AUDIT_RESULT',
          dictItems: [
            { text: '同意', value: 10041001 },
            { text: '驳回', value: 10041002 }
          ]
        },
        {
          title: '驳回原因(备注)',
          dataIndex: 'REJECT_REASON'
        }
      ];
    },
    // 同步table数据
    handleSyncTableData(list) {
      this.syncTableData = list;
    },
    // 刷新
    handleRefesh() {
      this.fetchParams = { ...this.fetchParams };
    },
    // 显示弹窗
    handleShowPanel() {
      this.showPanel = true;
      this.$nextTick(() => {
        this.fetchParams = Object.assign({}, this.fetchParams, { xhrAbort: false, roNo: this.roNo });
      });
    }
  }
};
</script>

<style scoped></style>
